import request from '@/utils/request'

/**
 * 查询字典类型列表
 */
export function getDictTypeList(query?: any) {
  return request.get('/system/dict/type/list', query)
}

/**
 * 查询字典类型详细
 */
export function getDictType(dictId: number) {
  return request.get(`/system/dict/type/${dictId}`)
}

/**
 * 新增字典类型
 */
export function addDictType(data: any) {
  return request.post('/system/dict/type', data, {
    showLoading: true,
    showSuccess: true,
    successMsg: '字典类型新增成功',
  })
}

/**
 * 修改字典类型
 */
export function updateDictType(data: any) {
  return request.put('/system/dict/type', data, {
    showLoading: true,
    showSuccess: true,
    successMsg: '字典类型修改成功',
  })
}

/**
 * 删除字典类型
 */
export function delDictType(dictId: number) {
  return request.delete(`/system/dict/type/${dictId}`, {}, {
    showLoading: true,
    showSuccess: true,
    successMsg: '字典类型删除成功',
  })
}

/**
 * 导出字典类型
 */
export function exportDictType(query?: any) {
  return request.post('/system/dict/type/export', query, {
    responseType: 'blob',
    showLoading: true,
  })
}

/**
 * 获取字典选择框列表
 */
export function optionSelect() {
  return request.get('/system/dict/type/optionselect')
}

/**
 * 刷新字典缓存
 */
export function refreshCache() {
  return request.delete('/system/dict/type/refreshCache', {}, {
    showLoading: true,
    showSuccess: true,
    successMsg: '刷新缓存成功',
  })
}

